package com.zhiziai.aiproxy.controller;

import com.zhiziai.aiproxy.constants.BusinessCode;
import com.zhiziai.aiproxy.dto.JsonVo;
import com.zhiziai.aiproxy.service.MidjourneyServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


@Controller
@Slf4j
@RequestMapping("/midjourney")
public class MidJourneyController {

    @Autowired
    private MidjourneyServiceImpl midjourneyService;

    @RequestMapping("/imgGenEncrypt")
    @ResponseBody
    public Object imgGenEncrypt(Long userId, String prompt,Integer genNum, String sign ) {
        try {
            return new JsonVo(BusinessCode.SUCCESS.getValue(), BusinessCode.SUCCESS.getMsg(), midjourneyService.encryptImgGen(userId,prompt,genNum,sign));
        } catch (Exception e) {
            log.error("imgGenEncrypt error", e);
            return new JsonVo(BusinessCode.ERROR.getValue(), e.getMessage());
        }
    }

    @RequestMapping("/imgVariationEncrypt")
    @ResponseBody
    public Object imgVariationEncrypt(Long userId, String taskId,Integer index, String sign ) {
        try {
            return new JsonVo(BusinessCode.SUCCESS.getValue(), BusinessCode.SUCCESS.getMsg(), midjourneyService.encryptImgVariation(userId,taskId,index,sign));
        } catch (Exception e) {
            log.error("imgVariationEncrypt error", e);
            return new JsonVo(BusinessCode.ERROR.getValue(), e.getMessage());
        }
    }


}
